package org.example.orderservice.Controller;

import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import lombok.extern.slf4j.Slf4j;
import org.example.orderservice.OrderServiceApplication;
import org.example.orderservice.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController
@RequestMapping("/order")
public class OrderController {

    @Value("${server.port}")
    private String serverPort;
    @Autowired
    OrderService orderService;
    @GetMapping("/getOrder")
    public String getOrder() {
        System.out.println("Come here to get order...==");
        return "Order Service form:" + serverPort;
    }
    @GetMapping("/orderCount")
    public String OrderCount(@RequestParam int count, HttpServletRequest request, HttpServletResponse response) {
        log.info("Come here to get order....123====");
        if (count == 500||count == 404) {
            response.setStatus(count);
        }
        return"10/count:"+10/count+"<br>form:"+serverPort;
    }
}
